--[[
 -- *名称:test
 -- *描述:测试类
 -- *版权:Copyright © 2016-2018 深圳市三只小熊科技有限公司 版权所有
 -- *作者:Administrator
 -- *创建日期:2017-11-08
 -- *修改日期:2017-11-08
 -- @return [description]
 ]]
require(basePath .."util/profiler")
local SuitAnalysisFactory = require(basePath.."suit/suitanalysisfactory");
local Card = require(basePath .. "domain/ddzcard")
local StraightTypeAnalyzer = require(basePath.."suit/straight/straighttypeanalyzer"); --顺子
local SuperBombTypeAnalyzer = require(basePath.."suit/superbomb/superbombtypeanalyzer"); --超级炸弹
local ThreeTypeAnalyzer = require(basePath.."suit/three/threetypeanalyzer"); --三条
local ThreeStraightTypeAnalyzer = require(basePath.."suit/threestraight/threestraighttypeanalyzer"); --三顺
local ThreeTakePairTypeAnalyzer = require(basePath.."suit/threetakepair/threetakepairtypeanalyzer"); --三带二
local ThreeTakePairPlusTypeAnalyzer = require(basePath.."suit/threetakepairplus/threetakepairplustypeanalyzer"); --三带二翅膀
local ThreeTakeSingleTypeAnalyzer = require(basePath.."suit/threetakesingle/threetakesingletypeanalyzer"); --三带一
local ThreeTakeSinglePlusTypeAnalyzer = require(basePath.."suit/threetakesingleplus/threetakesingleplustypeanalyzer");  --三带一翅膀检测                  
local BombTypeAnalyzer =  require(basePath.."suit/bomb/bombtypeanalyzer");  --炸弹
local FourTakePairTypeAnalyzer = require(basePath.."suit/fourtakepair/fourtakepairtypeanalyzer");  --四带二

local SingleAnalyzer = require(basePath .. "suit/single/singletypeanalyzer") ;
local PairAnalyzer  = require(basePath .. "suit/pair/pairtypeanalyzer") ;
local PairStraightAnalyzer = require(basePath .. "suit/pairstraight/pairstraighttypeanalyzer") ;
local FourTakeSingleAnalyzer = require(basePath .. "suit/fourtakesingle/fourtakesingletypeanalyzer") ;
local SoftBombAnalyzer = require(basePath .. "suit/softbomb/softbombtypeanalyzer") ;
local MissileAnalyzer= require(basePath .. "suit/missile/missiletypeanalyzer") ;


local Cards = require(basePath .. "domain/cards");
local M = {}

local analysisFactory = pokercore.new(SuitAnalysisFactory);
--analysisFactory:addSuitAnalyzer(pokercore.new(StraightTypeAnalyzer));
-- analysisFactory:addSuitAnalyzer(pokercore.new(SuperBombTypeAnalyzer))
-- analysisFactory:addSuitAnalyzer(pokercore.new(ThreeTypeAnalyzer));
-- analysisFactory:addSuitAnalyzer(pokercore.new(ThreeStraightTypeAnalyzer));
--analysisFactory:addSuitAnalyzer(pokercore.new(ThreeTakePairTypeAnalyzer));
-- analysisFactory:addSuitAnalyzer(pokercore.new(ThreeTakePairPlusTypeAnalyzer));
-- analysisFactory:addSuitAnalyzer(pokercore.new(FourTakePairTypeAnalyzer));
-- analysisFactory:addSuitAnalyzer(pokercore.new(PairAnalyzer));
-- analysisFactory:addSuitAnalyzer(pokercore.new(SingleAnalyzer));
-- analysisFactory:addSuitAnalyzer(pokercore.new(FourTakeSingleAnalyzer));
--analysisFactory:addSuitAnalyzer(pokercore.new(ThreeTakeSingleTypeAnalyzer));
--analysisFactory:addSuitAnalyzer(pokercore.new(ThreeTakeSinglePlusTypeAnalyzer));
-- analysisFactory:addSuitAnalyzer(pokercore.new(BombTypeAnalyzer)); 
-- analysisFactory:addSuitAnalyzer(pokercore.new(PairStraightAnalyzer));
--analysisFactory:addSuitAnalyzer(pokercore.new(SoftBombAnalyzer));
 analysisFactory:addSuitAnalyzer(pokercore.new(MissileAnalyzer));



M.doSuitTest = function()
	--print("#################牌型测试开始########################")
	local testCards = {} ;
    local tempCards = {4,5,6,7,8} ;
	for i=1,#tempCards do
		 local tempCard = pokercore.new(Card,CardShape.DIAMOND,tempCards[i],(tempCards[i]==6) and true or false):revalue() ;
        -- local tempCard2 = pokercore.new(Card,CardShape.HEART,tempCards[i],(tempCards[i]==6) and true or false):revalue() ;
		 -- --print(tempCard);
	     table.insert(testCards,tempCard);
         --table.insert(testCards,tempCard2);
	end
    local cards =  pokercore.new(Cards,testCards)
    local types = analysisFactory:listPossibleTypes(cards:clone(),nil,nil,true);
    if not types or #types == 0 then
    	--print("找不到对应的牌型");
    else
    	local typesStr = "" ;
    	for _,v in ipairs(types) do
    		typesStr = typesStr .. tostring(v).." | ";
    	end
    	--print("找到对应的牌型 为",typesStr);
    	for _,type in pairs(types) do
    		--print("----------------------");
    		--print("cards clone->",cards:clone());
    		local cardsList = analysisFactory:analysisLaizi(cards:clone(), nil, type);
    		for _,cardsTemp in pairs(cardsList) do

    			--print("找到了->",cardsTemp);
    			--print("\n");
    		end
    	end
    end
	--print("#################牌型测试结束########################")
end





M.doSuitListTest = function()
   --print("#################提牌测试开始########################")
   local testCards = {} ;
   --local tempCards = {4,5,6,7,8,9,10,11,12} ;
   --local tempCards = {3,3,3,3,4,4,5,5,6,6} ;
   --local tempCards = {3,3,3,3,4,4,4,4,6,6} ;
   local tempCards = {16,17} ;
    for i=1,#tempCards do
         local tempCard = pokercore.new(Card,CardShape.DIAMOND,tempCards[i],(tempCards[i]==6) and true or false):revalue() ;
         table.insert(testCards,tempCard);
    end
    local cards =  pokercore.new(Cards,testCards)
    --列出所有牌型
    local types = analysisFactory:listAbstractSuitType(false);
    if  not types or #types == 0 then
        --dump(testCards,"找不到对应的牌型");
    else
        --dump(types,"包含的牌型为:")
        for _,type in ipairs(types) do
            --print(type,"currentType->");
            local cardsList = analysisFactory:listInTypePossibleCards(pokercore.clone(cards),nil,type);
            --print("#################找到如下牌型########################")
            for _,cardsTemp in ipairs(cardsList) do
                --print("cardsTemp->",cardsTemp);
            end
        end
    end
    
    --print("#################提牌测试结束########################")
end












profiler = newProfiler("call")
profiler:start()

--M.doSuitTest();
M.doSuitListTest();
local outfile = io.open( "use_time.txt", "w+" )
profiler:report( outfile )
outfile:close();


return M ;